package com.project.controller;

import com.project.bean.UserBean;
import org.apache.catalina.mbeans.UserMBean;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;

@Controller
public class TestController {
    @RequestMapping("show")
    public String show(HttpServletRequest req){
        //绑定共享数据
        req.setAttribute("name","张三");
        req.setAttribute("age",20);

        List<UserBean> list=new ArrayList<>();
        list.add(new UserBean(1,"张三","158888888888"));
        list.add(new UserBean(3,"张是","158888888888"));
        list.add(new UserBean(2,"张的","158851533888"));
        list.add(new UserBean(5,"张非","158883513888"));
        list.add(new UserBean(4,"张任","158888833888"));

        req.setAttribute("list",list);

        //请求转发到指定页面
        return "/show.html";
    }
}
